package cn.com.mr01.lianxi.mr_lianxi_08;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class TokenizerMapper extends Mapper<LongWritable, Text, Text, Text> {

	Text k = new Text();
	Text n = new Text();

	/**
	 * map 中的值设置成<"1001","zhangsan	语文	2001">
	 * 
	 * <"1001","河北省	石家庄	裕华区">
	 */
	@Override
	protected void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {

		// 1. 切分
		String[] words = value.toString().split("\t");

		k.set(words[0]);
		String result = "";
		for (int i = 1; i < words.length; i++) {
			result += words[i];
		}
		n.set(result);
		context.write(k, n);
	}
}
